<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Images_model  extends MY_Model  {

    public $table = 'images';

	public function __construct() {
		$this->class_name = get_class ( $this );
		parent::__construct( $this->class_name, $this->table );
		parent::init( $this->class_name, $this->table );
	}
	
	public function get($product,$limit = 0){
		$this->db->select($this->table . ".url");
		
        $this->db->where($this->table . '.product_id',$product);
        
        $this->db->order_by('sort','asc');
        
        $this->db->group_by($this->table . ".url");
        
        if ($limit){
        	$query = $this->db->get($this->table,$limit);
        } else {
        	$query = $this->db->get($this->table);
        }
        
        return $query;
      }
}